home *** CD-ROM | disk | FTP | other *** search
/ Champak 52 / Volume 52 - JOGO DISK .iso / Games / scoobycastillotenebroso.swf / scripts / frame_1 / DoAction.as
Text File  |  2007-10-01  |  5KB  |  184 lines

  1. function CN_Game_Object()
  2. {
  3.    this.timedScreenArray = new Array();
  4.    this.depth_i = 0;
  5.    this.offScreenOffset = 700;
  6.    this.curScreen = null;
  7. }
  8. function CN_Timer(screen, parent, endTime)
  9. {
  10.    this.screen = screen;
  11.    this.mc = screen.mc.timer;
  12.    this.parent = parent;
  13.    this.mc.caller = this;
  14.    this.endTime = endTime * 1000;
  15.    this.active = false;
  16. }
  17. CN_Game_Object.prototype.Continue = function()
  18. {
  19.    if(this.curScreen != null)
  20.    {
  21.       this.RemoveScreen(this.curScreen);
  22.    }
  23.    if(this.timedScreenArray.length == 0)
  24.    {
  25.       gotoAndStop(7);
  26.    }
  27.    else
  28.    {
  29.       this.curScreen = this.timedScreenArray.shift();
  30.       this.ShowScreen(this.curScreen);
  31.       gotoAndStop(6);
  32.    }
  33. };
  34. CN_Game_Object.prototype.ExternalGraphicsAreLoaded = function()
  35. {
  36.    var allLoaded = true;
  37.    var i = 0;
  38.    while(i < this.timedScreenArray.length)
  39.    {
  40.       if(!this.timedScreenArray[i].isLoaded)
  41.       {
  42.          allLoaded = false;
  43.          break;
  44.       }
  45.       i++;
  46.    }
  47.    return allLoaded;
  48. };
  49. CN_Game_Object.prototype.GetExternalParameters = function()
  50. {
  51.    if(_root.sw1 != null)
  52.    {
  53.       this.timedScreenArray[0] = new Object();
  54.       this.timedScreenArray[0].path = _root.sw1;
  55.       this.timedScreenArray[0].duration = _root.sw2;
  56.       this.timedScreenArray[0].link = _root.sw4;
  57.    }
  58.    if(_root.sw5 == 1)
  59.    {
  60.       var array_i = this.timedScreenArray.length;
  61.       this.timedScreenArray[array_i] = new Object();
  62.       if(_root.sw5 != 1)
  63.       {
  64.          this.timedScreenArray[array_i].path = _root.sw5;
  65.       }
  66.       else
  67.       {
  68.          this.timedScreenArray[array_i].path = "orbitPowered/orbitPowered.swf";
  69.       }
  70.       if(_root.sw6 != null)
  71.       {
  72.          this.timedScreenArray[array_i].duration = _root.sw6;
  73.       }
  74.       else
  75.       {
  76.          this.timedScreenArray[array_i].duration = "3";
  77.       }
  78.       if(_root.sw7 != null)
  79.       {
  80.          this.timedScreenArray[array_i].link = _root.sw7;
  81.       }
  82.       else
  83.       {
  84.          this.timedScreenArray[array_i].link = null;
  85.       }
  86.    }
  87.    var array_i = this.timedScreenArray.length;
  88.    var next_i = 8;
  89.    while(_root["sw" + next_i] != null)
  90.    {
  91.       this.timedScreenArray[array_i] = new Object();
  92.       this.timedScreenArray[array_i].path = _root["sw" + next_i];
  93.       if(_root.sw6 != null)
  94.       {
  95.          this.timedScreenArray[array_i].duration = _root["sw" + ++next_i];
  96.       }
  97.       else
  98.       {
  99.          this.timedScreenArray[array_i].duration = "5";
  100.       }
  101.       if(_root.sw7 != null)
  102.       {
  103.          this.timedScreenArray[array_i].link = _root["sw" + ++next_i];
  104.       }
  105.       else
  106.       {
  107.          this.timedScreenArray[array_i].link = null;
  108.       }
  109.       array_i++;
  110.       next_i++;
  111.    }
  112. };
  113. CN_Game_Object.prototype.LaunchOrbitPopup = function()
  114. {
  115.    if(_root.sw5 == 1)
  116.    {
  117.       getUrl("javascript:popupOrbitCode( )", "");
  118.    }
  119. };
  120. CN_Game_Object.prototype.LoadExternalGraphic = function(screen, depth)
  121. {
  122.    _root.attachMovie("externalFileHolder","holder" + depth,depth);
  123.    screen.mc = _root["holder" + depth];
  124.    screen.mc.caller = screen;
  125.    screen.mc.slot.loadMovie(screen.path);
  126. };
  127. CN_Game_Object.prototype.MainMovieIsLoaded = function()
  128. {
  129.    if(_root.getBytesLoaded() == _root.getBytesTotal())
  130.    {
  131.       return true;
  132.    }
  133.    return false;
  134. };
  135. CN_Game_Object.prototype.PreloadExternalGraphics = function()
  136. {
  137.    var i = 0;
  138.    while(i < this.timedScreenArray.length)
  139.    {
  140.       this.LoadExternalGraphic(this.timedScreenArray[i],i + 1);
  141.       this.timedScreenArray[i].mc._x = this.offScreenOffset;
  142.       i++;
  143.    }
  144. };
  145. CN_Game_Object.prototype.RemoveScreen = function(screen)
  146. {
  147.    screen.mc.slot.unloadMovie();
  148.    screen.mc.removeMovieClip();
  149.    delete screen;
  150. };
  151. CN_Game_Object.prototype.ShowScreen = function(screen)
  152. {
  153.    screen.mc._x = 0;
  154.    screen.mc._y = 0;
  155.    screen.timer = new CN_Timer(screen,this,screen.duration);
  156.    screen.timer.Start();
  157. };
  158. CN_Game_Object.prototype.toString = function()
  159. {
  160.    return "CN_Game_Object";
  161. };
  162. CN_Timer.prototype.Start = function()
  163. {
  164.    this.active = true;
  165.    this.startTime = getTimer();
  166. };
  167. CN_Timer.prototype.Tick = function()
  168. {
  169.    if(getTimer() - this.startTime >= this.endTime)
  170.    {
  171.       _root.EndTimerAdapter(this.parent);
  172.       this.active = false;
  173.    }
  174. };
  175. CN_Timer.prototype.toString = function()
  176. {
  177.    return "CN_Timer";
  178. };
  179. EndTimerAdapter = function(parent)
  180. {
  181.    parent.Continue();
  182. };
  183. myGameObject = new CN_Game_Object();
  184.